﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace MonopolyGame
{
    class Dies
    {
        static Random rnd;
        public bool isRolled { get; private set; }

        public int result { get; private set; }
        public Dies()
        {
            this.isRolled = false;
            this.result = 0;
        }

        private void Result()
        {
            rnd=new Random();
            result = rnd.Next(1, 13);

            //StreamReader rdr = new StreamReader("ROLLS.TXT");
            //string first = rdr.ReadToEnd();

            //StringBuilder b = new StringBuilder(first);
            //b.Append("ROLL : " + result);
            //rdr.Close();

            StreamWriter wrt = new StreamWriter("ROLLS.TXT");
            wrt.WriteLine(result);
            wrt.Close();

        }

        public int Update()
        {
            if (isRolled)
            {
                Result();
            }
            isRolled = false;
            return result--;
        }

        public void roll()
        {
            isRolled = true;
        }
    }
}
